<%@page import="com.liferay.portal.kernel.language.LanguageUtil"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="javax.portlet.WindowState"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="doan.quanlycanbo.portlet.util.PortletKeysExt" %>
<%@page import="doan.quanlycanbo.portlet.model.donvi" %>
<%@page import="doan.quanlycanbo.portlet.service.donviLocalServiceUtil" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/init.jsp" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>

<%
	String tabsName = "tab.qldv.donvi";
	List<donvi> depList = donviLocalServiceUtil.getByParent(PortletKeysExt.DEPARTMENT_PARENT_ID);
%>

<script type="text/javascript">	
	function <portlet:namespace />saveDocument(){
		document.<portlet:namespace />fm.<portlet:namespace />gioithieuchung.value = parent.<portlet:namespace />gioithieuchung.getHTML();		
		submitForm(document.<portlet:namespace />fm);		
	}

	function <portlet:namespace />initContentEditor() {
		document.<portlet:namespace />fm.<portlet:namespace />gioithieuchung.value = "<%= UnicodeFormatter.toString("") %>";
		return "<%= UnicodeFormatter.toString("") %>";
	};
</script>

<portlet:actionURL name="updateDepartment" var="updateDepartmentURL"/>

<liferay-ui:tabs names="<%= tabsName %>"  />
	<aui:form name="fm" Method="post" action="<%= updateDepartmentURL.toString() %>" enctype="multipart/form-data">
		<aui:input type="hidden" name="idDonvi" value=""/>
		<table style="border: none; width: 100%;">
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Ten don vi") %></td>
				<td align="left"><aui:input name="tendonvi" label="" value=""  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-select.agency.parent","Don vi cha") %></td>
				<td><aui:select name="donvicha" label=""  style="width:200px">
						<aui:option value="0">---&nbsp;<%=LanguageUtil.get(pageContext, "managecontacts.agency.add-select.all.agency","Tat ca") %> &nbsp;---</aui:option>
						<% for(donvi dep1 : depList) {%>
							<aui:option value="<%= dep1.getMadonvi() %>" >  <%=dep1.getTendonvi() %></aui:option>
							<%
   								List<donvi> depByParent = donviLocalServiceUtil.getByParent(dep1.getMadonvi());
  								if(!depByParent.isEmpty()) { 
  								for(donvi dep2 : depByParent) { 
  							%>  
								<aui:option  value="<%=dep2.getMadonvi() %>"  > &nbsp;&nbsp;&nbsp;&nbsp; <%= dep2.getTendonvi() %> </aui:option>
				
								<%} %>
							<%} %>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-address","Dia chi") %></td>
				<td><aui:input name="diachi" label="" value=""  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-phone.number","So dien thoai") %></td>
				<td><aui:input name="dienthoai" label="" value="" style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-fax","Fax") %></td>
				<td><aui:input name="fax" label="" value="" style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-email","Email") %></td>
				<td><aui:input name="email" label="" value="" style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-website","Website") %></td>
				<td><aui:input name="website" label="" value=""  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-website","Hinh Anh") %></td>
				<td><aui:input name="hinhanh" type="file" label=""></aui:input> </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-introduce","Gioi thieu") %></td>
				<td> <liferay-ui:input-editor name='<%= renderResponse.getNamespace() + "gioithieuchung" %>'
						 toolbarSet="liferay-article" width="100%" height="430px"
						 initMethod='<%= renderResponse.getNamespace() + "initContentEditor"%>' />
						 <input name="<portlet:namespace />gioithieuchung" type="hidden" />
				</td>
			</tr>			
							 
		</table>
		
			<input type="button" value='<%=LanguageUtil.get(pageContext, "managecontacts.agency.add-button.save","Luu") %>' onClick="javascript:<portlet:namespace />saveDocument();">
			<aui:button type="button" value='<%=LanguageUtil.get(pageContext, "managecontacts.agency.add-button.cancel","Thoat") %>' onClick="history.back();"/>	
	</aui:form>

<%!
	public static final String EDITOR_WYSIWYG_IMPL_KEY = "editor.wysiwyg.portal-web.docroot.html.portlet.journal.edit_article_content.jsp";
	public static final String EDITOR_WYSIWYG_IMPL_KEY_DEFAULT = "editor.wysiwyg.default";
	public static final String EDITOR_WYSIWYG_IMPL_KEY_SIMPLE = "editor.wysiwyg.default";
%>





